#include <iostream>

using namespace std;

class Rectangle {
public:
    // 无参构造器
    Rectangle();

    // 构造函数
    Rectangle(int newLength, int newWidth);

    // 调整矩形长宽
    void setRectangle(int newLength, int newWidth);

    // 显示数据成员值
    void showRectangle();

    // 析构函数
    ~Rectangle() {
        cout << "Bye!" << endl;
    };

private:
    int length, width, area;
};

Rectangle::Rectangle() {
    setRectangle(0, 0);
}

Rectangle::Rectangle(int newLength, int newWidth) {
    Rectangle::setRectangle(newLength, newWidth);
}

void Rectangle::setRectangle(int newLength, int newWidth) {
    length = newLength > 0 ? newLength : 0;
    width = newWidth > 0 ? newWidth : 0;
    area = length * width;
}

void Rectangle::showRectangle() {
    cout << "length = " << length << endl;
    cout << "width = " << width << endl;
    cout << "area = " << area << endl;
}

int main() {
    Rectangle rectangle = Rectangle(10, 20);
    rectangle.showRectangle();
    rectangle.setRectangle(30, 40);
    rectangle.showRectangle();
    return 0;
}